package p3_entities;

import java.io.Serializable;
import javax.persistence.*;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import com.sun.xml.bind.CycleRecoverable;
import com.sun.xml.bind.CycleRecoverable.Context;

import java.math.BigDecimal;
import java.util.List;


/**
 * The persistent class for the balances database table.
 * 
 */
@Entity
@Table(name="balances")

@NamedQueries({
				
})


public class Balance implements Serializable, CycleRecoverable {
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name="UserId", unique=true, nullable=false)
	private int userId;

	@Column(name="LindenEuros", nullable=false, precision=10)
	private BigDecimal lindenEuros = new BigDecimal(0);

	

	//bi-directional many-to-one association to Usermessage
	@OneToMany(mappedBy="balance")	
	@LazyCollection(LazyCollectionOption.FALSE)
	private List<Lindenmovement> movements;

	public Balance() {
    	
    }

    public Balance(int userId_) {
    	this.userId = userId_;
    }

	public int getUserId() {
		return userId;
	}



	public void setUserId(int userId) {
		this.userId = userId;
	}



	public BigDecimal getLindenEuros() {
		return lindenEuros;
	}



	public void setLindenEuros(BigDecimal lindenEuros) {
		this.lindenEuros = lindenEuros;
	}



	public List<Lindenmovement> getMovements() {
		return movements;
	}



	public void setMovements(List<Lindenmovement> movements) {
		this.movements = movements;
	}



	@Override
	public Object onCycleDetected(Context arg0) {
		Balance obj = new Balance(this.userId);
		  
		return obj;  
	}


	
	
}